home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
C
/
Frameworks
/
Extension Shell 1.5
/
Sample Extensions (1.5)
/
Quadra INIT ƒ
/
Gestalt.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-11-01
|
3KB
|
149 lines
/* NAME:
Gestalt.c
WRITTEN BY:
Dair Grant
DESCRIPTION:
This file contains a code resource to be installed as a Gestalt
selector.
NOTES:
We call the original gestaltMachineType selector, then munge the
return value to pretend we're always a Quadra 950.
___________________________________________________________________________
*/
//=============================================================================
// Include files
//-----------------------------------------------------------------------------
#include <Gestalt.h>
#include "A4Stuff.h"
#include "SetupA4.h"
#include "ES Address Table.h"
#include "QI Constants.h"
//=============================================================================
// Types
//-----------------------------------------------------------------------------
typedef pascal OSErr (*GestaltSelectorProcPtr)(OSType gestaltSelector, long *gestaltResponse);
//=============================================================================
// Global Variables
//-----------------------------------------------------------------------------
GestaltSelectorProcPtr gPreviousSelector;
Boolean gAlreadyRan = false;
//=============================================================================
// Private function prototypes
//-----------------------------------------------------------------------------
pascal OSErr main(OSType gestaltSelector, long *gestaltResponse);
//=============================================================================
// main : Entry point to our code resource.
//-----------------------------------------------------------------------------
// Note : We call the original Gestalt selector first then fudge the
// result to be a Quadra. We don't actually need to call the
// original routine, because it just so happens that the
// value returned isn't used to store other information apart
// from the machine type.
//
// However, if the result was some kind of bit structure, we
// would need to use this method.
//-----------------------------------------------------------------------------
pascal OSErr main(OSType gestaltSelector, long *gestaltResponse)
{ long oldA4;
ESAddressTable *theAddressTable;
OSErr theErr;
// Set up A4
#ifndef powerc
oldA4 = SetCurrentA4();
#endif
// If we've not already been called, do our one time initialisation stuff
if (!gAlreadyRan)
{
Gestalt(kMacTypeAddressTable, (long *) &theAddressTable);
gPreviousSelector = (GestaltSelectorProcPtr) ((long) theAddressTable->theTable[kMacType]);
gAlreadyRan = true;
}
// Call the original routine
theErr = gPreviousSelector(gestaltSelector, gestaltResponse);
// Fudge the response to what we want
*gestaltResponse = gestaltQuadra950;
theErr = noErr;
// Restore A4 and return
#ifndef powerc
SetA4(oldA4);
#endif
return(theErr);
}